import { createStore } from 'vuex'

const store = createStore({
  state: {
    count: 1,
  },
  actions: {
    add({ commit }, newVal) {
      //调用的mutations里声明的方法add
      commit('add', newVal)
    },
  },
  mutations: {
    add(state, newVal) {
      state.count += newVal
    },
  },
  getters: {
    getCount(state) {
      return state.count
    },
  },
})

export default store
